﻿<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>持名法州主页</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/IconExtension.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/china.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/echarts.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
	<!--菜单处理-->
    $(function () {
        $('#myduihuakuang').dialog({
            title: '修改密码',
            width: 400,
            height: 200,
            closed: true,
            modal: true
        });
        $('#btn').linkbutton({
            iconCls: 'icon-search'
        });
    })
    function xg() {
	    //打开修改密码的窗口
        $('#myduihuakuang').dialog("open");
    }

    //验证用户输入的合法性
    $(function () {
        $("#oldPassword").validatebox({
            required: true,
            missingMessage:"不能为空",
        });
        /* 自定义确认密码验证 */
        $.extend($.fn.validatebox.defaults.rules, {
            checkpassword: {
                validator: function(value, param){
                    var pwd = $(param[0]).val();

                    return value==pwd;
                },
                message: "两次密码不一致"
            }
        });
        $("#newPassword1").validatebox({
            required: true,
            missingMessage:"不能为空",
            validType:"length[6,8]",
            invalidMessage:"密码长度为6-8位",
        })
        $("#newPassword2").validatebox({
            required: true,
            missingMessage:"不能为空",
            validType:"checkpassword['#newPassword1']"
        })
    })

    function updatepwd() {
        $("#myform").form('submit', {
            url:"/cmfz/admin/updatePassword",
            onSubmit: function(){
                // do some check
                // return false to prevent submit;
                var aa = $("#myform").form("validate");
                alert(aa);
                return aa;
            },
            success:function(data){
                var abc = JSON.parse(data);
                if(abc.pd){
                    alert("修改成功");
                    $('#myduihuakuang').dialog("close");
                    window.location.reload();
                }else {
                    alert("修改失败");
                }if (abc.no==false){
                    alert("原密码错误");
                }
            }
        });
    }


    $(function () {
        $.ajax({
            url:"${pageContext.request.contextPath}/menu/select",
            dataType:"JSON",
            type:"get",
            success:function (data) {
                console.info(data)
                //展示一级菜单
                //遍历数据  第一个参数是被遍历的参数 第二个参数是匿名函数
                //匿名函数的第一个参数  自定义形参 （代表下标）
                //第二个参数 自定义的形参（代表被遍历到的元素）

                $.each(data,function (index1,menu1) {
                    //获取一级菜单对象menu1中的二级菜单数据  拼接出来要在content区域展示的内容
                    //遍历一级中的二级类别
                    var c = "";
                    $.each(menu1.child,function (index2,menu2) {
                        c+="<div style='text-align: center'><a href='#' class='easyui-linkbutton' data-options=\"iconCls:'icon-search',plain:true\" onclick=\"addTabs('" + menu2.menuName + "','" + menu2.menuUrl + "')\">" + menu2.menuName + "</a></div>";
                    })
                    $('#aa').accordion('add', {
                        title: menu1.menuName,
                        content: c ,
                        selected: false
                    });
                })
            }
        })
    })
    //点击事件   点击一个按钮增加一个选项卡
    function addTabs(menuName,menuUrl) {

	    //不重复打开  判断对应的页面有没有被打开   如果打开了  就选中被打开页面  如果没有被打开  就打开一个新的
        //1判断页面有没有被打开
        var exists = $('#tt').tabs('exists',menuName);
        if(exists){
            $('#tt').tabs('select',menuName);
        }else {
            $('#tt').tabs('add',{
                title:menuName,
                //通过url获取对应的jsp  填充到当前页面
                href:"${pageContext.request.contextPath}"+menuUrl ,
                closable:true,
                tools:[{
                    iconCls:'icon-mini-refresh',
                    handler:function(){
                        alert('refresh');
                    }
                }]
            });
        }
    }


















</script>

</head>
<body class="easyui-layout">
    <div data-options="region:'north',split:true" style="height:60px;background-color:  #5C160C">
    	<div style="font-size: 24px;color: #FAF7F7;font-family: 楷体;font-weight: 900;width: 500px;float:left;padding-left: 20px;padding-top: 10px" >持名法州后台管理系统</div>
    	<div style="font-size: 16px;color: #FAF7F7;font-family: 楷体;width: 300px;float:right;padding-top:15px">欢迎您:${sessionScope.admin.username} &nbsp;<a href="#" onclick="xg()" class="easyui-linkbutton" data-options="iconCls:'icon-edit'">修改密码</a>&nbsp;&nbsp;<a href="${pageContext.request.contextPath}/admin/quit" class="easyui-linkbutton" data-options="iconCls:'icon-01'">退出系统</a></div>
    </div>   
    <div data-options="region:'south',split:true" style="height: 40px;background: #5C160C">
    	<div style="text-align: center;font-size:15px; color: #FAF7F7;font-family: 楷体" >&copy;百知教育 htf@zparkhr.com.cn</div>
    </div>   
       
    <div data-options="region:'west',title:'导航菜单',split:true" style="width:220px;">
    	<div id="aa" class="easyui-accordion" data-options="fit:true">

        </div>
    </div>   
    <div data-options="region:'center'">
    	<div id="tt" class="easyui-tabs" data-options="fit:true,narrow:true,pill:true">   
		    <div title="主页" data-options="iconCls:'icon-neighbourhood',"  style="background-image:url(image/shouye.jpg);background-repeat: no-repeat;background-size:100% 100%;"></div>
		</div>  
    </div>


    <div id="myduihuakuang">
        <form id="myform">
            输入当前密码:<input type="password" id="oldPassword" name="oldPassword"><br/>
            输入新密码:<input type="password" id="newPassword1" name="newPassword"><br/>
            请再次输入新密码:<input type="password" id="newPassword2">
        </form>

        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="updatepwd()" >提交</a>
    </div>

</body> 
</html>